<%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">
    $(function() {
     init();
    });
    var mallShopCardruleModule = (function(){

     var module = {
      init :function(){

      },
      saveview : function(){
        addOneTab("添加油卡", "mallShopCardruleController.do?saveview");
      },
      editview : function(title,url, id){
           gridname=id;
           var rowsData = $('#'+id).datagrid('getSelections');
           if (!rowsData || rowsData.length==0) {
               tip('Please select edit item');
               return;
           }
           var oilCardNo=rowsData[0].cardNo;
           for(var i=1;i<rowsData.length;i++){
               oilCardNo+=","+rowsData[i].cardNo;
           }
           var url ="mallShopCardruleController.do?editview"+"&cardNos="+oilCardNo;
           var id="editview";
           //addTabs({id:id,title:"编辑油卡",close: true,url: url});
           addOneTab("编辑油卡", url);
       }

     }
     return module;
    })();
    function view(cardno) {
        addOneTab("油卡详情","mallShopCardruleController.do?view&cardno="+cardno);
    }
    var dateModule = (function () {
     /*初始化时间查询*/
     var initDate = function () {
      $("input[name='modifyTimeStart']").attr("class", "Wdate").click(function () {
       WdatePicker({dateFmt: 'yyyy-MM-dd'});
      });
      $("input[name='modifyTimeEnd']").attr("class", "Wdate").click(function () {
       WdatePicker({dateFmt: 'yyyy-MM-dd'});
      });
     };
     var module = {
      init: function () {
       initDate();
      }
     };
     return module;
    })();
    function init() {
     var datagrid = $("#mallShopCardruleListtb");
     var shuntListForm = datagrid.find("div[name='searchColums']").find("form#mallShopCardruleListForm");
     shuntListForm.html("");
     shuntListForm.append($("#searchColumsDiv").html());
     shuntListForm.css('display', 'block');
     $("#searchColumsDiv").html('');
     dateModule.init();
    }
    function myDelObj(id, isdelete,isMine,isAdmin) {
        if(isMine=='true'||isAdmin=='true'){
            var url = "mallShopCardruleController.do?del&id="+id+"&isdelete="+isdelete;
            gridname="mallShopCardruleList";
            doSubmit(url,gridname);
        }else{
            tip("只有项目人员或管理人员才能启用和禁用");
        }

    }
    function isModifyClick(thiz) {
       if(!$(thiz).prop("checked")){
         $("#modifyTimeStart").val("");
         $("#modifyTimeEnd").val("");
        $("#modifyTimeStart").attr("disabled", "disabled");
        $("#modifyTimeEnd").attr("disabled", "disabled");
        $("#isModifyFlag").val("0");
       } else {
        $("#modifyTimeStart").removeAttr("disabled");
        $("#modifyTimeEnd").removeAttr("disabled");
        $("#isModifyFlag").val("1");
       }
    }
    function openProjectSelect() {
     $.dialog.setting.zIndex = 9999;
     $.dialog({
      content: 'url:mallProjectController.do?projects',
      zIndex: 2300,
      title: '选择项目组',
      lock: true,
      width: '400px',
      height: '350px',
      opacity: 0.4,
      button: [
       {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackSearch, focus: true},
       {
        name: '<t:mutiLang langKey="common.cancel"/>', callback: function () {
       }
       }
      ]
     }).zindex();
    }
    //选择项目中后
    function callbackSearch() {
     var iframe = this.iframe.contentWindow;
     var rowsData = iframe.$('#projectList').datagrid('getSelections');

     if (!rowsData || rowsData.length==0) {
      $("#projectId").val("");
      $("#projectName").val("");
     }
     if (rowsData.length==1) {
      $("#projectId").val(rowsData[0].id);
      $("#projectName").val(rowsData[0].projectname);
     }
    }

    function openShopSelect() {
     $.dialog.setting.zIndex = 9999;
     $.dialog({
      content: 'url:mallShopController.do?chooseList',
      zIndex: 2300,
      title: '选择商铺',
      lock: true,
      width: '600px',
      height: '400px',
      opacity: 0.4,
      button: [
       {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackShopSearch, focus: true},
       {
        name: '<t:mutiLang langKey="common.cancel"/>', callback: function () {
       }
       }
      ]
     }).zindex();
    }
    //选择项目中后
    function callbackShopSearch() {
     var iframe = this.iframe.contentWindow;
     var rowsData = iframe.$('#mallShopList').datagrid('getSelections');

     if (!rowsData || rowsData.length==0) {
      $("#shopName").val("");
     }
     if (rowsData.length==1) {
      $("#shopName").val(rowsData[0].shopname);
     }
    }

    function openOilSelect() {
        $.dialog.setting.zIndex = 9999;
        $.dialog({
            content: 'url:mallOilsupplierController.do?chooseList',
            zIndex: 2300,
            title: '选择石油供应商',
            lock: true,
            width: '300px',
            height: '300px',
            opacity: 0.4,
            button: [
                {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackOilSearch, focus: true},
                {
                    name: '<t:mutiLang langKey="common.cancel"/>', callback: function () {
                }
                }
            ]
        }).zindex();
    }
    //选择项目中后
    function callbackOilSearch() {
        var iframe = this.iframe.contentWindow;
        var rowsData = iframe.$('#oilSupplierList').datagrid('getSelections');

        if (!rowsData || rowsData.length==0) {
            $("#supplierName").val("");
        }
        if (rowsData.length==1) {
            $("#supplierName").val(rowsData[0].suppliername);
        }
    }

    function openAssociatedPersonsSelect() {
        $.dialog.setting.zIndex = 9999;
        $.dialog({
            content: 'url:mallProjectEmployeeController.do?chooseList',
            zIndex: 2300,
            title: '选择相关人员',
            lock: true,
            width: '300px',
            height: '300px',
            opacity: 0.4,
            button: [
                {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackAssociatedPersonsSearch, focus: true},
                {
                    name: '<t:mutiLang langKey="common.cancel"/>', callback: function () {
                }
                }
            ]
        }).zindex();
    }
    //选择项目中后
    function callbackAssociatedPersonsSearch() {
        var iframe = this.iframe.contentWindow;
        var rowsData = iframe.$('#associatedPersonsList').datagrid('getSelections');

        if (!rowsData || rowsData.length==0) {
            $("#userName").val("");
        }
        if (rowsData.length==1) {
            $("#userName").val(rowsData[0].userName);
        }
    }
</script>

<div id="searchColumsDiv"><input id="_sqlbuilder" name="sqlbuilder" type="hidden">
  <link rel="stylesheet" href="plug-in/Validform/css/style.css" type="text/css">
  <link rel="stylesheet" href="plug-in/Validform/css/tablefrom.css" type="text/css">
  <span style="display:-moz-inline-box;display:inline-block;"><span
          style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
          title="店铺名称">店铺名称：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                          id="shopName" name="shopName" onclick="openShopSelect()" readonly class="inuptxt" style="width: 100px"></span><span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="关联项目组">关联项目组：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                            id="projectName" name="projectName" onclick="openProjectSelect()" readonly class="inuptxt" style="width: 100px"></span><span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="关联人员">关联人员：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                         id="userName" name="userName" onclick="openAssociatedPersonsSelect()" readonly class="inuptxt" style="width: 100px"></span><span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="石油供应商">石油供应商：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                           id="supplierName" name="supplierName" onclick="openOilSelect()" readonly class="inuptxt" style="width: 100px"></span>

        <span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="油卡卡号">油卡卡号：</span><input onkeypress="EnterPress(event)" onkeydown="EnterPress()" type="text"
                                         name="cardNo" class="inuptxt" style="width: 100px"></span><span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 80px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="是否禁用">是否禁用：</span><select name="isdelete" width="100" style="width: 104px"> <option
         value="">---请选择---</option><option value="1">是</option><option value="0">否</option></select></span>
<br/>
 <span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 100px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="有修改">有修改：<input id="isModify" name="isModify" type="checkbox" onclick="isModifyClick(this)"/></span>
      <input type="hidden" id="isModifyFlag" name="isModifyFlag" value="0"/>
  </span>
 <span
         style="display:-moz-inline-box;display:inline-block;"><span
         style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 100px;text-align:right;text-overflow:ellipsis;-o-text-overflow:ellipsis; overflow: hidden;white-space:nowrap; "
         title="修改/录入时间">修改/录入时间：</span>
     <select name="enterType" id="enterType">
         <option value="0">录入时间</option>
         <option value="1">修改时间</option>
     </select>
   <input onkeypress="EnterPressCus(event)" onkeydown="EnterPressCus()" type="text" id="modifyTimeStart" name="modifyTimeStart" class="Wdate" style="width: 135px" disabled>
   至
   <input onkeypress="EnterPressCus(event)" onkeydown="EnterPressCus()" type="text" id="modifyTimeEnd" name="modifyTimeEnd" class="Wdate" style="width: 135px" disabled>
  </span>
</div>


<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="mallShopCardruleList" title="油卡卡号维护" actionUrl="mallShopCardruleController.do?datagrid" idField="id" fit="true"
           queryMode="group" checkbox="true" >
   <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
   <t:dgCol title="店铺名称" field="shopName"  query="true"  width="120"></t:dgCol>
   <t:dgCol title="商品名称" field="productName"   width="120"></t:dgCol>
   <t:dgCol title="关联项目组" field="projectName"   width="120" query="true"></t:dgCol>
   <t:dgCol title="关联人员" field="userName"   width="120" query="true"></t:dgCol>
      <t:dgCol title="项目组修改" field="editPrj"></t:dgCol>
      <t:dgCol title="人员修改" field="editUser" ></t:dgCol>
   <t:dgCol title="石油供应商" field="supplierName"   width="120" query="true"></t:dgCol>
   <t:dgCol title="油卡卡号" field="cardNo" query="true"  width="120"></t:dgCol>
   <t:dgCol title="创建人" field="createUserId"   width="120"></t:dgCol>
   <t:dgCol title="创建时间" field="createTime" formatter="yyyy-MM-dd hh:mm:ss"  width="120"></t:dgCol>
   <t:dgCol title="是否禁用" field="isdelete"  width="120" replace="是_1,否_0" query="true" dictionary="is_delete"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
      <t:dgCol title="isMine" field="isMine" hidden="true"></t:dgCol>
      <t:dgCol title="isAdmin" field="isAdmin" hidden="true"></t:dgCol>
   <t:dgFunOpt title="禁用" funname="myDelObj(id,isdelete,isMine,isAdmin)" exp="isdelete#eq#0"/>
   <t:dgFunOpt title="启用" funname="myDelObj(id,isdelete,isMine,isAdmin)" exp="isdelete#eq#1"/>
   <t:dgFunOpt title="查看" funname="view(cardNo)" />
   <t:dgToolBar title="录入" icon="icon-add"  funname="mallShopCardruleModule.saveview"></t:dgToolBar>
   <t:dgToolBar title="编辑" icon="icon-edit"  funname="mallShopCardruleModule.editview"></t:dgToolBar>
  <%-- <t:dgToolBar title="编辑" icon="icon-edit" url="mallShopCardruleController.do?addorupdate" funname="update"></t:dgToolBar>
   <t:dgToolBar title="查看" icon="icon-search" url="mallShopCardruleController.do?addorupdate" funname="detail"></t:dgToolBar>--%>
  </t:datagrid>
  </div>
 </div>